package com.eightywork.life.activity;

import cn.jpush.android.api.JPushInterface;

import com.eightywork.life.R;
import com.eightywork.life.fragment.SpaceContentFragment;
import com.eightywork.life.fragment.SpaceFragment;
import com.eightywork.life.model.Space;
import com.umeng.analytics.MobclickAgent;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

public class InfoActivity extends BaseActivity implements OnClickListener {
	private TextView name, mobile, sex, marry, home, birthday, note;
	private ViewGroup marryLayout, qqLayout, birthLayout, birthCityLayout, sexLayout;
	private View marryLine,qqLine,birthLine,birthCityLine,sexLine;
	private ImageButton buttonLeft;
	private Space space;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_info);
		initView();
	}

	@Override
	public void onResume() {		
		super.onResume();
		JPushInterface.onResume(this);
	    MobclickAgent.onResume(this);
	}
	
	@Override
	public void onPause() {
	    super.onPause();
		JPushInterface.onPause(this);
	    MobclickAgent.onPause(this);
	}


	public void initView() {
		initHeader("个人资料");
		name = (TextView) findViewById(R.id.name);
		mobile = (TextView) findViewById(R.id.mobile);
		sex = (TextView) findViewById(R.id.sex);
		marry = (TextView) findViewById(R.id.marry);
		home = (TextView) findViewById(R.id.home);
		birthday = (TextView) findViewById(R.id.birthday);
		note = (TextView) findViewById(R.id.note);
		buttonLeft = (ImageButton) findViewById(R.id.button_left);
		marryLayout = (ViewGroup) findViewById(R.id.marry_layout);
		birthLayout = (ViewGroup) findViewById(R.id.birth_layout);
		birthCityLayout = (ViewGroup) findViewById(R.id.birthcity_layout);
		sexLayout = (ViewGroup) findViewById(R.id.sex_layout);
		marryLine = findViewById(R.id.marray_line);
		birthLine = findViewById(R.id.birth_line);
		birthCityLine = findViewById(R.id.birthcity_line);
		sexLine = findViewById(R.id.sex_line);
		buttonLeft.setOnClickListener(this);
	}

	private void initData() {
		space = SpaceContentFragment.space;
		name.setText(space.getName());
		mobile.setText(space.getMobile());
		sex.setText(space.getSex());
		marry.setText(space.getMarry());
		home.setText(space.getBirthcity());
		birthday.setText(space.getBirth());
		if (space.getPrivacy().get("birthcity").getAsString().equals("3")) {
			birthCityLayout.setVisibility(View.GONE);
			birthCityLine.setVisibility(View.GONE);
		}
		if (space.getPrivacy().get("birth").getAsString().equals("3")) {
			birthLayout.setVisibility(View.GONE);
			birthLine.setVisibility(View.GONE);
		}
//		if (space.getPrivacy().get("qq").getAsString().equals("3")) {
//
//		}
		if (space.getPrivacy().get("marry").getAsString().equals("3")) {
			marryLayout.setVisibility(View.GONE);
			marryLine.setVisibility(View.GONE);
		}
		if (space.getPrivacy().get("sex").getAsString().equals("3")) {
			sexLayout.setVisibility(View.GONE);
			sexLine.setVisibility(View.GONE);
		}
//		if (space.getPrivacy().get("mobile").getAsString().equals("3")) {
//		}
	}

	@Override
	public void onClick(View v) {
		if (buttonLeft == v) {
			finish();
		}
	}

}
